<?php
session_start();
include_once "checkAdmin.php";
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>修改车辆资料</title>
    <style>
        h1 {
            text-align: center;
        }

        .main {
            width: 50%;
            margin: 0 auto
        }

        .main table {
            width: 100%
        }
        #x0,#x1{width: 30px;height: 30px;display: none}
        #code{cursor: pointer;}
    </style>
</head>
<body>
<h1>资料修改</h1>
<?php
$id = isset($_GET['id']) ? $_GET['id'] : 0;
$sql = "select * from car where id = $id";
include_once "conn.php";
$result = mysqli_query($conn,$sql);
$info = mysqli_fetch_array($result);
if(!$info){
    echo "<script>alert('车辆未找到');history.back();</script>";
    exit;
}
?>
<div class="main">
    <form action="postCarModify.php" method="post" onSubmit="return Validator.Validate(this,3)" enctype="multipart/form-data">
        <table style="border-collapse:collapse " border="1" width="100%" cellpadding="10" bordercolor="gray" cellspacing="0">
            <tr>
                <td align="center">车辆名称</td>
                <td align="left">
                    <input name="carname" value="<?php echo $info['carname'];?>">
                </td>
            </tr>
            <tr>
                <td align="center">车辆描述</td>
                <td align="left">
                    <textarea name="description"><?php echo $info['description'];?></textarea>
                </td>
            </tr>
            <tr>
                <td align="center">车辆图片</td>
                <td align="left">
                    <input type="file" name="carpic"><input type="hidden" name="MAX_FILE_SIZE" value="2048" />
                </td>
            </tr>
            <tr>
                <td align="center">
                    <input type="submit" value="提交"><input type="hidden" name="carid" value="<?php echo $id;?>">
                </td>
                <td align="left">
                    <input type="reset" value="重置">
                </td>
            </tr>
        </table>
    </form>
</div>
</body>
<script src="js.js"></script>
<script src="jquery.js"></script>

</html>